<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="umsroot.css">
<TITLE>
Porting Programs to plain ECLiPSe
</TITLE>
</HEAD>
<BODY >
<A HREF="umsroot136.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot135.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="umsroot138.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc300">22.2</A>&nbsp;&nbsp;Porting Programs to plain ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP></H2>
If you want to use ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> to do further development of your application,
it is probably advantageous to modify it such that it runs under plain
ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>.
In the following we summarise the main aspects that have to be considered
when doing so.
<UL CLASS="itemize"><LI CLASS="li-itemize">
In general, it is almost always possible to add to your program
a small routine that fixes the problem, rather than to modify
the source of the application in many places.
E.g. name clashes are easier fixed
by using the <A HREF="../bips/kernel/modules/local-1.html"><B>local/1</B></A><A NAME="@default1181"></A> declaration rather than to rename
the clashing predicate in the whole application program.<BR>
<BR>
<LI CLASS="li-itemize">Due to lack of standardisation, some subtle differences in the
syntax exist between Prolog systems. See <A HREF="umsroot143.html#syntaxdiff">A.4</A>
for details. ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> has a number of options that make it possible
to configure its behaviour as desired.<BR>
<BR>
<LI CLASS="li-itemize">ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> has the <TT>string</TT> data type which is not present in Prolog
of the Edinburgh family.
Double-quoted items are parsed as strings in ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>, while they are
lists of integers in other systems and when the compatibility
packages are used (cf. chapter <A HREF="umsroot025.html#chapstring">5.4</A>).<BR>
<BR>
<LI CLASS="li-itemize">I/O predicates of the <B>see</B> and <B>tell</B> group are not builtins
in ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>, but they are provided in the <B>cio</B> library.
Call <TT>lib(cio)</TT> in order to have them available (cf. appendix A).
Similarly for <A HREF="../bips/lib/numbervars/index.html"><B>numbervars/3</B></A><A NAME="@default1182"></A>.<BR>
<BR>
<LI CLASS="li-itemize">In ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>, some builtins raise events in cases where they just fail
in other systems, e.g. <TT>arg(1,2,X)</TT> fails in C-Prolog, but
raises a type error in ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>.
If some code relies on such behaviour, it is best to modify it by
adding an explicit check like
<PRE CLASS="verbatim">
        ..., compound(T), arg(N, T, X), ...
</PRE>
Another alternative is to redefine the arg/3 builtin, using
:/2 to access the original version:
<PRE CLASS="verbatim">
:- local arg/3.
arg(N, T, X) :-
        compound(X),
 eclipse_language:arg(N, T, X).
</PRE>
A third alternative
is to define an error handler which will fail the predicate
whenever the event is raised. In this case:
<PRE CLASS="verbatim">
my_type_error(_, arg(_, _, _)) :- !, fail.
my_type_error(E, Goal) :- error(default(E), Goal).
:- set_error_handler(5, my_type_error/2).
</PRE><BR>
<BR>
<LI CLASS="li-itemize">As the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> compiler does not accept procedures whose clauses
are not consecutive in a file, you have to load the library <B>scattered.pl</B>
if you want to compile such procedures.</UL>
<HR>
<A HREF="umsroot136.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot135.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="umsroot138.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
